class Solution {
    public:
        int numberOfArrays(vector<int>& differences, int lower, int upper) {
            long long init=0;
            long long Max=0;
            long long Min=0;
            for(int i=0;i<differences.size();i++){
                init+=differences[i];
                Max=max(Max,init);//找到初始区间最大值
                Min=min(Min,init);//找到初始区间最小值
            }
            return max(upper-Max-lower+Min+1,0LL);
        }
    };